library(tidyverse)
library(readr)
chic <- read_csv("ggplot2/ggModify/chicago-nmmaps.csv")

# 有几种组合图的方法，最简单的方法是patchwork包。
#   cowplot, gridExtra也有类似的功能
p1 <- ggplot(chic, aes(x = date, y = temp,
                       color = season)) +
        geom_point() +
        geom_rug() +
        labs(x = "Year", y = "Temperature (°F)")

p2 <- ggplot(chic, aes(x = date, y = o3)) +
        geom_line(color = "gray") +
        geom_point(color = "darkorange2") +
        labs(x = "Year", y = "Ozone")

library(patchwork)
p1 + p2

# 我们可以通过“/”来改变另个图形的排列：
p1 / p2

# 而且嵌套图也是可以的：
(g + p2) / p1


# 布局思想，它允许创建复杂的组合:
layout <- "
AABBBB#
AACCDDE
##CCDD#
##CC###
"

p2 + p1 + p1 + g + p2 +
  plot_layout(design = layout)

